var template_=`<div>
    <el-form :inline="true" :model="findForm" ref="findform" style="margin-top: 10px"
        class="demo-form-inline" size="mini" label-width="80px">
        <el-form-item label="动作">
        <el-input v-model="findForm.name" :clearable="true"
            @clear="getData('find')" @keyup.enter.native="getData('find')" placeholder="动作"></el-input>
        </el-form-item>

        <el-form-item label="类型">
            <el-select v-model="findForm.zd" @change="getSelect" :clearable="true"  placeholder="字段"> <!--multiple allow-create -->
            <el-option
                v-for="item in findForm.zdlist"
                :key="item.value" :label="item.label" :value="item.value">
            </el-option>
        </el-select>

        <el-select v-model="findForm.nr" @change="getData('find')"
            filterable allow-create :clearable="true"  placeholder="选择"> <!--multiple allow-create -->
            <el-option
                v-for="item in findForm.nrlist"
                :key="item.value" :label="item.label" :value="item.value">
            <span style="float: left">{{ item.label.substring(0, 24) }}</span>
            <span style="float: right; color: #8492a6; font-size: 13px">{{ item.num }}</span>
            </el-option>
        </el-select>
        </el-form-item>

        <el-form-item>
        <el-button type="primary" @click="getData('find')">查询</el-button>
        </el-form-item>

    </el-form>

    <!--显示 table-->
    <el-table fit :data="tableData" stripe @sort-change="sort_change" height="700" v-loading="loading"
        ref="expandTable" style="width: 100%">

        <el-table-column type="index" label="序号" width="50"> </el-table-column>
        <el-table-column prop="ID" label="ID" v-if="false" sortable="custom"></el-table-column>
        <el-table-column prop="user" label="操作者" width="100"></el-table-column>
        <el-table-column prop="action" label="动作"></el-table-column>
        <el-table-column prop="ip" label="IP" width="120"></el-table-column>
        <el-table-column prop="sj" label="时间"></el-table-column>

    </el-table>

    <CustomizePagination :page="currentPage" :total=pageTotal :size="pageSize"
        @page-change="handlePageChange" />
</div>`

export default {
    name:'log',
    data() {
        return {
          findForm: {
            zdlist:logList,  //自定义 固定,  //自定义 固定
            nrlist:'',      //动态获取
            zd:'action',
            nr:'',
          },
  
          tableData: [],
          loading: false,
          pageSize:15,
          currentPage:1,
          pageTotal:0,
          sort:'id',
          order:'DESC',
        }
      },
      methods: {
        getData(v) {
          if (v=='find')  //点【查询】时，要从第一页开始
            this.currentPage=1
  
          this.loading=true
          axios.post('controller/log.php?lx=GetListData', {
            table:'logs',
            Find:this.findForm,
            page:this.currentPage,
            size:this.pageSize,
            sort:this.sort,
            order:this.order,
          }).then((res) => {
            if (res.data.code==200) {
              this.loading=false
              this.pageTotal=parseInt(res.data.total)
              this.tableData=res.data.data
              this.permissions=res.data.permissions  //增删修 权限
            }
            token_err(res)
          });
        },
        getSelect() {
          axios.post('controller/data.php?lx=getSelect', {
            table:'log',
            zd:this.findForm.zd,
          }).then((res) => {
            if (res.data.code==200) {
              this.findForm.nr=''
              this.findForm.nrlist=res.data.data
            }
          });
        },
  
        select_chang(val){  //el-select @change
          this.findForm.type=val
          this.getData()
        },
        handlePageChange(val,size){
            this.currentPage=val
            this.pageSize=size
            this.getData()
          },
        sort_change(column, prop, order){
          //console.log(column, prop, order)
          this.colSort=column
          console.log(this.colSort)
          this.getData()
        },
        rowClick(row, column, event){
          if(column.label!="操作")
            this.$refs.expandTable.toggleRowExpansion(row, row.expanded);
        },
  
      },
      created(){},
      mounted(){
        this.getData()
        this.getSelect()
      },
      components:{
           CustomizePagination : () => import('../components/pagination.js')  //第二种方式
      },
      template: template_
};
